package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.RcglInvestigateCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglInvestigateResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.RcglInvestigateUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.RcglInvestigateEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface RcglInvestigateConvert {

    RcglInvestigateConvert INSTANCE = Mappers.getMapper(RcglInvestigateConvert.class);

    RcglInvestigateEntity createTo(RcglInvestigateCreateDTO s);

    RcglInvestigateEntity update(RcglInvestigateUpdateDTO s);

    RcglInvestigateResultDTO convert(RcglInvestigateEntity s);

    default RcglInvestigateEntity create(RcglInvestigateCreateDTO s, Long tenantId) {
        RcglInvestigateEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        return entity;
    }
}
